﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ehost
{
    public partial class UpdateIPFrom : Form
    {
        private mainForm mainForm;

        public UpdateIPFrom()
        {
            InitializeComponent();
        }

        public UpdateIPFrom(mainForm form)
        {
            InitializeComponent();
            mainForm = form;
            Host h = (Host)mainForm.getTreeView().SelectedNode.Tag;

            textBox1.Text = h.ip;
            textBox2.Text = h.comment;
        }

        private void UpdateIPFrom_Load(object sender, EventArgs e)
        {
           
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Host h = (Host)mainForm.getTreeView().SelectedNode.Tag;
            h.ip = textBox1.Text;
            h.comment = textBox2.Text;

            mainForm.getTreeView().SelectedNode.Tag = h;


            String content =h.ip;
            if(!String.IsNullOrEmpty(h.comment))content+="  ("+h.comment+")";

            mainForm.getTreeView().SelectedNode.Text = content;

            mainForm.addChange(h.lineNum, h);

            Close();
            
        }
    }
}
